<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('管理员列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>



                            <li>
                                <p>姓名：</p>
                                <input type="text" name="realName"/>
                            </li>

                            <li>
                                <p>权限：</p>
                                <input type="text" name="companyQx"/>
                            </li>

                            <li>
                                <p>手机号：</p>
                                <input type="text" name="staffPhone"/>
                            </li>

                            <li>
                                <p>系统权限：</p>
                                <select name="staffState">
                                    <option value="">请选择</option>
                                    <option value="开启">开启</option>
                                    <option value="关闭">关闭</option>
                                </select>
                            </li>

                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>

                            </li>
                        </ul>
                    </div>
                </form>
            </div>
            <!-- Button trigger modal -->
            <button type="button" class="btn btn-primary btn-lg" >
                Launch demo modal
            </button>

            <!-- Modal -->
            <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                <div class="modal-dialog" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                            <h4 class="modal-title" id="myModalLabel">Modal title</h4>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">员工姓名：</label>
                            <div class="col-sm-8">
                                <input name="realname" class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">手机号：</label>
                            <div class="col-sm-8">
                                <input name="staffphone" class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">登录姓名：</label>
                            <div class="col-sm-8">
                                <input name="loginName" class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">登录密码：</label>
                            <div class="col-sm-8">
                                <input name="loginPwd" class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">角色类型：</label>
                            <div class="col-sm-8">
                                <select name="">
                                    <option value="">请选择</option>
                                    <option value="普通用户">普通用户</option>
                                    <option value="管理员">管理员</option>
                                </select>
                            </div>
                        </div>

                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal" onclick="$.operate.edit()" shiro:hasPermission="system:staff:edit">提交</button>
                            <button type="button" class="btn btn-primary">发送短信通知</button>
                        </div>
                    </div>
                </div>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:staff:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:staff:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:staff:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:staff:export">
                    <i class="fa fa-download"></i> 导出
                 </a>

            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />

    <script th:inline="javascript" type="text/javascript">
        var editFlag = [[${@permission.hasPermi('system:staff:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:staff:remove')}]];
        var prefix = ctx + "system/tstaff";

        function toupd(staffId) {
            $(function(){
                $.ajax({
                    url:'/system/tstaff/getOne',
                    type:'get',
                    data:{"staffId":staffId},
                    dataType:'json',
                    success:function (data) {
                        console.log(data);
                        $("[name='staffphone']").val(data.staffPhone);
                        $("[name='realname']").val(data.realName);
                        $("[name='staffId']").val(data.staffId);
                    }
                })
            })
        }
        function toAdd(id){
            alert(id);
        }
        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/tadd",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "管理员",
                columns: [{
                    checkbox: true
                },
                {
                    field : 'staffId', 
                    title : '员工id',
                    visible: false
                },
                    {
                        field : 'realName',
                        title : '姓名'
                    },

                {
                    field : 'staffPhone', 
                    title : '手机号'
                },


                    {
                        field : 'companyName',
                        title : '所属部门'
                    },

                    {
                        field : 'staffState',
                        title : '系统权限状态'
                    },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.staffId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.staffId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        actions.push('<input type="button" value="开通系统权限"  onclick="toupd(\'' + row.staffId + '\')" data-toggle="modal" data-target="#myModal">');

                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

    </script>
</body>
</html>